package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.UserSignIn;
import com.sc.nft.entity.vo.DailyParticipationStatisticsVO;
import com.sc.nft.entity.vo.LotteryDataPageVO;
import com.sc.nft.entity.vo.ParticipationDateDataVO;
import com.sc.nft.mapper.UserSignInMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Slf4j
@Repository
public class UserSignInDao extends ServiceImpl<UserSignInMapper, UserSignIn> {

    /**
     * 根据活动Id签到活动的参与人数
     * @param activityBasicsId
     * @return
     */
    public Long getAttendUserCount(Long activityBasicsId) {
        return baseMapper.getAttendUserCount(activityBasicsId);
    }

    /**
     * 根据活动Id获取签到活动的参与次数
     * @param activityBasicsId
     * @return
     */
    public Long getAttendCount(Long activityBasicsId) {
        return baseMapper.getAttendCount(activityBasicsId);
    }

    /**
     * 签到活动获取日参与统计数据
     * @param activityBasicsId
     * @param startTime
     * @return
     */
    public List<DailyParticipationStatisticsVO> dayStatisticalData(Long activityBasicsId, Date startTime) {
        return baseMapper.getDayStatisticalData(activityBasicsId,startTime);
    }

    /**
     * 获取签到活动详情列表信息
     * @param id
     * @param page
     * @param userTel
     * @return
     */
    public IPage<LotteryDataPageVO> getlotteryDataPage(Long id, Page page,String userTel) {
        return baseMapper.getlotteryDataPage(id,page,userTel);
    }

    /**
     * 从补签记录中查询用户补签了多少次
     * @param userId
     * @param activityBasicsId
     * @return
     */
    public Integer getSupplementarySignatureCount(Long userId, Long activityBasicsId) {
        return baseMapper.getSupplementarySignatureCount(userId,activityBasicsId);
    }

    /**
     * 查询用户是否签到
     * @param userId
     * @param activityBasicsId
     * @return
     */
    public int getIsSignInByUserId(Long userId,Long activityBasicsId) {
        return baseMapper.getIsSignInByUserId(userId,activityBasicsId);
    }

    /**
     * 根据活动Id获取签到来源为0的用户签到记录
     * @param id
     * @return
     */
    public List<UserSignIn> getSignInTimeByActivityBasicsId(Long id) {
        return baseMapper.getSignInTimeByActivityBasicsId(id);
    }

    /**
     * 根据活动Id和用户Id获取用户正常签到记录
     * @param activityBasicsId
     * @param userId
     * @return
     */
    public List<UserSignIn> getSignInTimeByActivityBasicsIdAndUserId(Long activityBasicsId, Long userId) {
        return baseMapper.getSignInTimeByActivityBasicsIdAndUserId(activityBasicsId,userId);
    }
}
